using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Design.ValidatorNodes;

using EntLibContrib.Validation.Configuration;

namespace EntLibContrib.Validation.Design.Nodes
{
    public class CompositeRulesetValidatorNode : SingleValidatorNodeBase
    {
        private string targetRulesets;
        private ValidationSpecificationSource source;
        private string configurationSourceName;

        public CompositeRulesetValidatorNode()
            : this(new CompositeRulesetValidatorData(Resources.CompositeRulesetValidatorNodeName))
        {
        }

        public CompositeRulesetValidatorNode(CompositeRulesetValidatorData validatorData)
            : base(validatorData)
        {
            targetRulesets = validatorData.TargetRulesets;
            source = validatorData.Source;
            configurationSourceName = validatorData.ConfigurationSourceName;
        }

        [SRCategory("CategoryGeneral", typeof(Resources))]
        [SRDescription("DescriptionSource", typeof(Resources))]
        public ValidationSpecificationSource Source
        {
            get { return source; }
            set { source = value; }
        }

        [SRCategory("CategoryGeneral", typeof(Resources))]
        [SRDescription("DescriptionConfigurationSourceName", typeof(Resources))]
        public string ConfigurationSourceName
        {
            get { return configurationSourceName; }
            set { configurationSourceName = value; }
        }

        [SRCategory("CategoryGeneral", typeof(Resources))]
        [SRDescription("DescriptionTargetRulesets", typeof(Resources))]
        public string TargetRuleSets
        {
            get { return targetRulesets; }
            set { targetRulesets = value; }
        }

        public override ValidatorData CreateValidatorData()
        {
            CompositeRulesetValidatorData validatorData = new CompositeRulesetValidatorData(Name);

            validatorData.TargetRulesets = TargetRuleSets;
            validatorData.Source = Source;
            validatorData.ConfigurationSourceName = ConfigurationSourceName;

            return validatorData;
        }

    }
}
